﻿using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using RuoYi.Common.Tool;

namespace RuoYi.Admin.Controllers.Api
{
    public class CommonController : ApiController
    {
        /// <summary>
        /// 生成验证码
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task CaptchaImage()
        {
            string code = "";
            //生成验证码
            byte[] bt = VerifyCodeHelper.GetVerifyCode(out code);
            //Session中存储验证码
            //HttpContext.Session.SetString("LoginCaptcha", code);

            await DownloadAsync(bt, "Captcha", Encoding.UTF8);
        }
    }
}
